
/* Gets resource html from the server and inserts it in the HTML Object
 * which will be provided as part of the paramaters
 * 
 * @param String type   - POST or GET accepted
 * @param String url    - URL resource for the php file
 * @param Array data    - Array Object
 * @param Object field  - HTML object where the data will be inserted
 * @returns void
 */
var ajaxCall = function(type, url, data, field) {
    if (field.html().toString().trim().length === 0) {
        $.ajax({
            type: type,
            url: url,
            data: data,
            headers: {
                "Accept-Encoding": "gzip, deflate"
            },
            success: function(data, textStatus, jqXHR) {
                field.html(data);
            },
            error: function(jqXHR, textStatus, errorThrown) {
                console.log(jqXHR);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    }
};
